package com.skynet.supervision.aop.uac.beans;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.skynet.supervision.aop.dict.Dict;
import com.skynet.supervision.constants.DictDef;
import com.skynet.supervision.utils.Strings;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author xuchao
 * @date 2023-03-08 20:50
 */
@ApiModel
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UACUserInfo implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @ApiModelProperty(value = "用户ID")
    private String userId;

    /**
     * 用户账号
     */
    @ApiModelProperty(value = "用户账号")
    private String account;

    /**
     * 姓名
     */
    @ApiModelProperty(value = "姓名")
    private String name;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱")
    private String email;

    /**
     * 融云token
     */
    @ApiModelProperty(value = "融云token")
    private String rongCloudToken;

    /**
     * 所属部门名称
     */
    @ApiModelProperty(value = "所属部门名称")
    private String deptName;

    /**
     * 职务
     */
    @ApiModelProperty(value = "职务")
    private String titles;

    /**
     * 岗位
     */
    @ApiModelProperty(value = "岗位")
    private String deptPost;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    private String avatar;

    /**
     * 是否是司机
     */
    @ApiModelProperty(value = "是否是司机")
    private Boolean ifDriver=false;


    /**
     * 状态{0:已删除; 1:启用; 2:禁用}
     */
    @ApiModelProperty(value = "状态")
    private Integer status = 1;

    @ApiModelProperty(value = "性别")
    @Dict(DictDef.DICT_USER_SEX)
    private String sex;

    /**
     * 上次登录时间
     */
    @ApiModelProperty(value = "上次登录时间")
    private Long lastLoginTime;

    @JsonIgnore
    private String token;

    @JsonIgnore
    public Boolean isAnonymous(){
        return Strings.isEmpty(this.userId) || Strings.strcmp(this.userId,"anonymous");
    }

    public static UACUserInfo anonymous() {
        UACUserInfo anonymous = new UACUserInfo();
        anonymous.setUserId("anonymous");
        anonymous.setName("anonymous");
        return anonymous;
    }

    public static UACUserInfo empty() {
        return new UACUserInfo();
    }
}
